package com.hsh;

import java.io.RandomAccessFile;
import java.net.URL;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author shaohai.huang
 * @date 2021-12-17
 */
public class FIleChannelTest {
    public static void main(String[] args) throws Exception {
        URL url = FIleChannelTest.class.getResource("/chronos.yaml");
        System.out.println(url);
        RandomAccessFile rw1 = new RandomAccessFile(url.getFile(), "rw");
        FileChannel rw = rw1.getChannel();
        MappedByteBuffer map = rw.map(FileChannel.MapMode.READ_WRITE, 0, 1024 * 1024 * 8);
        while (map.hasRemaining()) {
            System.out.println(map.getChar());
        }

    }
}
